// 343.整数拆分
package Leetcode_Second_Brush;

public class Solution343 {
    public int integerBreak(int n) {
        if (n <= 3)
            return n - 1;

        int[] dp = new int[n + 1];

        for (int i = 0; i < n + 1; i++) {
            if (i <= 3)
                dp[i] = i;
            else {
                for (int j = 1; j <= i / 2; j++)
                    dp[i] = Math.max(dp[i], dp[j] * dp[i - j]);
            }
        }

        return dp[n];
    }
}
